#ifndef CAUDIO_H
#define CAUDIO_H

#include <vector>

#ifdef ENGINE_FMOD
#include <fmod.h>
#endif

class GLEngine;

struct CAudioSound
{
    int id;
    #ifdef ENGINE_FMOD
    FMOD_SOUND* fsound;
    FMOD_CHANNEL* fchannel;
    #endif
};

class CAudio
{
public:
	CAudio(GLEngine* engine, int sound_count);
	virtual ~CAudio();

	void update();

	void loadSound(const char* file_name, int id);

	void playSound(int id, int flags=0);
	void playStream(const char* file_name, int flags=0);

    void playMusic(const char* file_name);
    void playMusic();
    void stopMusic();

    CAudioSound* getSoundFromChannel(int ch);
    inline GLEngine* getEngine() { return m_Engine; }

private:
    #ifdef ENGINE_FMOD
	FMOD_SYSTEM* m_SoundSystem;
	std::vector<CAudioSound> m_Sounds;
	CAudioSound m_Music;
	CAudioSound** m_ChannelTracker;
    #endif
    GLEngine* m_Engine;
	bool m_Enabled;
};

#endif // CAUDIO_H
